import { cloneDeep } from "lodash-es"

export const useBaseShapeConfig = () => {
  const baseShapeConfig = {
    IText: {
      text: '文字编辑',
      width : 60,
      height : 60,
      fill : '#0066ccff',
      stroke: '#8822cc00',
      strokeWidth: 0,
      left: 20,
      top: 20
    },
    Triangle: {
      width: 100,
      height: 100,
      fill: '#00cccc00',
      stroke: '#00ccccff',
      strokeWidth: 2,
      left: 20,
      top: 20
    },
    Circle: {
      radius: 50,
      fill: '#8822cc00',
      stroke: '#8822ccff',
      strokeWidth: 2,
      left: 20,
      top: 20
    },
    Rect: {
      width : 100,
      height : 100,
      fill : '#cc226600',
      stroke: '#cc2266ff',
      strokeWidth: 2,
      left: 20,
      top: 20
    },
    Line: {
      width: 100,
      height: 1,
      fill: '#0066ccff',
      left: 20,
      top: 20
    },
    Arrow: {
      fill: '#ffffff88', 
      stroke: '#cc88ccff',
      strokeWidth: 2,
      angle: -90,
      objectCaching: false,
      left: 100,
      top: 150
    },
    Image: {
      src: ''
    },
    Mask: {}
  }

  const getConfigByType = (type, url = '') => {
    return type === 'Image'
      ? { url }
      : (cloneDeep(baseShapeConfig[type]) ?? {})
  }
  return {
    getConfigByType
  }  
}
